package com.scale.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 静态资源配置
 * @author crp
 * @since 2025-01-26
 */
@Configuration
public class StaticResourceConfig implements WebMvcConfigurer {
    
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 配置静态资源访问路径
        registry.addResourceHandler("/**")
                .addResourceLocations("classpath:/static/", "file:../");
        
        // 配置语音文件访问路径
        registry.addResourceHandler("/voice/**")
                .addResourceLocations("file:D:/programme/javaEE/scale/data/voice/");
        
        // 配置头像文件访问路径
        registry.addResourceHandler("/avatar/**")
                .addResourceLocations("file:D:/programme/javaEE/scale/data/avatar/");
    }
}
